<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>绑定样式</title>
    <script type="text/javascript" src="../js/vue.js"></script>
    <style>
        *{
            margin-top: 20px;
        }
        .basic{
            height: 100px;
            width: 500px;
            border: 2px solid;
            border-color: black;
        }
        .happy{
            background-color: pink;
        }
        .crazy{
            background-color: orangered;
        }
        .normal{
            background-color: aqua;
        }
        .circle{
            border-radius: 20px;
        }
    </style>
</head>
<body>
    <h2>绑定样式，字符串的方式。绑定的样式的类名不确定</h2>
    <div id="root" class="basic circle" :class="styleChange" @click="choose">
        <p>今天天气很：{{isHot}}</p>
        
    </div>
    <h2>也可以将样式存入数组，进行数组的操作。样式个数不确定，名字不确定。</h2>
        <hr>
        <h2>还可以对象绑定，即：个数确定，样式动态获取。</h2>
        <p>:class="styleChangeObj" @click.stop="choose"</p>
        <div class="basic circle">
            <p>今天天气很：{{isHot}}</p>
        </div>
    <hr>
    <h1>你要是很闲，还可以绑定style测试</h1>


    <script type="text/javascript">
        const vm = new Vue({
            el: "#root",
            data() {
                return {
                    isHot: '超级超级热呀，你怎么敢的呀',
                    styleChange: 'normal',
                    styleChangeObj:{
                        normal: true,
                        circle: false
                    }
                }
            },
            methods: {
                choose(){
                    const mod = ['happy', 'crazy', 'normal']
                    var index = Math.floor(Math.random()*3) 
                    console.log(index)
                    this.styleChange = mod[index]
                    console.log("isHot 被修改：",mod[index])
                }
            }
        })
        // vm.$watch('tag', { options })
    </script>
</body>
</html>